package com.firstcare.android_dylibrary;


import android.content.SharedPreferences;

import com.firstcare.android_dylibrary.bean.AccountProxy;
import com.firstcare.android_dylibrary.network.DYAPI;
import com.litesuits.orm.LiteOrm;
import com.rdxer.xxlibrary.base.BaseApplication;

/**
 * Created by LXF on 16/6/8.
 */

public class DYApplication extends BaseApplication {

    @Override
    public DYAPI getApi() {
        return (DYAPI) super.getApi();
    }
    public static String language_text="";
    // 当前用户
    private AccountProxy accountProxy = null;
    public AccountProxy getAccountProxy() {
        return accountProxy;
    }
    public void setAccountProxy(AccountProxy accountProxy) {
        this.accountProxy = accountProxy;
    }

    public static DYApplication getShared(){
        return (DYApplication) BaseApplication.getShared();
    }
    @Override
    public void onCreate() {
        super.onCreate();
        setApi(new DYAPI(getApplicationContext()));
        setDb(LiteOrm.newSingleInstance(getApplicationContext(),BuildConfig.db_File_Name));
        getDb().setDebugged(BuildConfig.DEBUG);
        AccountProxy.checkAccount();
        setLanguage();
    }
    public void setLanguage(){
        SharedPreferences shPreferences = getSharedPreferences(
                "update", MODE_PRIVATE);
        String result = shPreferences.getString("update_Language","");
        if (result.equals("english")){
            DYApplication.language_text="英文";
        }else{
            DYApplication.language_text="中文";
        }

    }

}
